package com.cn.transfer.jobhandler;

import com.cn.transfer.common.entity.General;
import com.cn.transfer.mapper.PuPurchaseOrderMapper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: weidian
 * @date: 2024/4/7 10:11
 * @Description: 采购订单到货日期为空时，加入最早日期
 */
@Slf4j
@Component
public class DateChangedXxlJob {

    @Autowired
    private PuPurchaseOrderMapper puPurchaseOrderMapper;

    @XxlJob("dateChanged")
    public void dateChanged(){
        List<General> purchaseOrderData = puPurchaseOrderMapper.getPurchaseOrderData();
        for (General purchaseOrderDatum : purchaseOrderData) {
            puPurchaseOrderMapper.updatePurchaseOrderData(purchaseOrderDatum.getPurchaseOrderCode(), purchaseOrderDatum.getMinRequireDate());
        }
    }
}
